package com.keyinong.wifiprint;

import java.io.DataOutputStream;
import java.io.IOException;
import java.io.OutputStream;

public class PrintUtils {
	private static OutputStream outputStream ;
	
	
	
	/**
	 * 复位打印机
	 */
	public static final byte[] RESET = {0x1b, 0x40};

	/**
	 * 左对齐
	 */
	public static final byte[] ALIGN_LEFT = {0x1b, 0x61, 0x00};

	/**
	 * 中间对齐
	 */
	public static final byte[] ALIGN_CENTER = {0x1b, 0x61, 0x01};

	/**
	 * 右对齐
	 */
	public static final byte[] ALIGN_RIGHT = {0x1b, 0x61, 0x02};

	/**
	 * 选择加粗模式
	 */
	public static final byte[] BOLD = {0x1b, 0x45, 0x01};

	/**
	 * 取消加粗模式
	 */
	public static final byte[] BOLD_CANCEL = {0x1b, 0x45, 0x00};

	/**
	 * 宽高加倍
	 */
	public static final byte[] DOUBLE_HEIGHT_WIDTH = {0x1d, 0x21, 0x11};

	/**
	 * 宽加倍
	 */
	public static final byte[] DOUBLE_WIDTH = {0x1d, 0x21, 0x10};

	/**
	 * 高加倍
	 */
	public static final byte[] DOUBLE_HEIGHT = {0x1d, 0x21, 0x01};

	/**
	 * 字体不放大
	 */
	public static final byte[] NORMAL = {0x1d, 0x21, 0x00};

	/**
	 * 设置默认行间距
	 */
	public static final byte[] LINE_SPACING_DEFAULT = {0x1b, 0x32};
	
	
	
	
	
	/**
	   * 设置打印格式
	   *
	   * @param command 格式指令
	   */
	  public static void selectCommand(byte[] command) {
	      try {
	    	  outputStream = new DataOutputStream(outputStream);
	          outputStream.write(command);
	          outputStream.flush();
	      } catch (IOException e) {
	          e.printStackTrace();
	      }
	  }
}
